<%-- 
    Document   : cart
    Created on : Mar 22, 2011, 9:53:58 PM
    Author     : Nguyen Hung
--%>



<%@page import="java.text.NumberFormat"%>
<%@page import="Business.Product"%>
<%@page import="Business.LineItem"%>
<%@page import="Business.Cart"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="WEB-INF/jspf/header.jspf"%>

<table border="1" width="600">
    <tr>
        <th class="borderheader"><strong>Sản Phẩm</strong></th>
        <th class="borderheader"><strong>Số lượng</strong></th>
        <th class="borderheader"><strong>Đơn Giá</strong></th>
        <th class="borderheader"><strong>Thành Tiền</strong></th>
        <th class="borderheader"> Xóa </th>
    </tr>

    <%
                NumberFormat nf = NumberFormat.getInstance();
                //nf.setMinimumFractionDigits(2);
                nf.setMaximumFractionDigits(2);
                Cart cart = (Cart) session.getAttribute("cart");
                ArrayList<LineItem> items = cart.getItems();
                for (LineItem item : items) {
                    Product product = item.getProduct();

    %>
    <tr>
        <td><%=product.getProductCode()%></td>
        <td><form action="<%=response.encodeURL("cart")%>" name="updatequantity" >
                <input type="text" size ="3"name="quantity" value ="<%= item.getQuantity()%>">
                <input type="hidden" name="productCode" value="<%=product.getProductCode()%>">
                <input type="submit" value="Update">
            </form>
        </td>

        <td><%=nf.format(product.getPrice())%></td>
        <td><%=nf.format(item.getTotal())%></td>
        <td>
            <form action="<%=response.encodeURL("cart")%>" name="remove">
                <input type = "hidden" name="productCode" value="<%=product.getProductCode()%>">
                <input type="hidden" name="quantity" value="0">
                <input type="submit" value="Xóa">
            </form>
        </td>
    </tr>
    <% }%>



</table>
<div class="shop_comand">
    <div class="shop_comand_btn">

        <input type="submit" onclick="window.location=&#39;http://localhost:8080/LaptopShop/payment.jsp&#39;;return false"  value="Thanh Toán" id="" tabindex="1000" class="btn_shop">
        <input type="submit" onclick="window.location=&#39;http://localhost:8080/LaptopShop/index.jsp&#39;;return false"name="" value="Mua thêm" id="" class="btn_shop" />
      
        <div style="color:Red;display:none;">

        </div>
    </div>
    <div class="shop_comand_text">
        <div class="to_text">
            Tổng tiền (VND):</div>
        <div class="to_price"><%=nf.format(cart.getTempCost())%> </div>
    </div>
</div>




<%@include file="WEB-INF/jspf/footer.jspf" %>